<template>
	<view class="content">
		<!-- <mescroll-uni @init="mescrollInit" @down="downCallback" @up="upCallback" > -->
		   <view class="list-container">
				<view class="shenhe-list" @tap="goinfo" v-for="(item,index) in list" :key="index" :data-id="item.id">
					<view class="clear shenhe-text" >
						<text class="left" style="font-size: 34rpx;color: #323232;">￥{{item.capital}}</text>
					</view>
					<view class="clear shenhe-text">
						<text class="left">{{item.addtime}}</text>
					</view>
					<text class="zhuangtai">{{item.is_check_name}}</text>
					<image src="../../static/img/to.png" class="go_icon"></image>
				</view>	
		   </view>
		   <image src="../../static/img/nodata.png" class="no-data" v-if="ishas1"  mode="widthFix"></image>
		<!-- </mescroll-uni> -->
	</view>
</template>

<script>
	import httpPath from '@/static/js/path.js';
	import {getlogin} from '@/static/js/login.js';
	import {fmoney} from '@/static/js/login.js';
	import {timestampToDate} from '@/static/js/login.js';
	import MescrollUni from "@/components/mescroll-uni/uni-load-more.vue";
	var  _self,
	page = 1;
	export default {
		data() {
			return {
				type: 0,
				list:[],
				dataList: [],
				name: '',
				user:{},
				loadingType: 0,
				ishas1:false,
				contentText: {
					contentdown: "上拉显示更多",
					contentrefresh: "正在加载...",
					contentnomore: "没有更多数据了"
				}
			};
		},
		onPullDownRefresh() {
			page=1
			_self.loadingType=0;
		    this.fnGetData();   
		    setTimeout(function () {
		            uni.stopPullDownRefresh();
		        }, 1000);
		},
		components: {
			MescrollUni
		},
		// components: {uniLoadMore},
		onLoad(e) {
			this.user = getlogin();
			if(!this.user.islogin){
				uni.showModal({
				   showCancel:false,
				   content:"您还没有登录，请登录"
				})
				uni.navigateTo({
					url:"../public/login"
				})
			}	
			page = 1;
			_self = this;
			_self.type = e.id;
			_self.fnGetData();
		},
		onShow() {
			this.user = getlogin();
			if(!this.user.islogin){
				uni.showModal({
				   showCancel:false,
				   content:"您还没有登录，请登录"
				})
				uni.navigateTo({
					url:"../public/login"
				})
			}	
			page = 1;
			_self.fnGetData();
		},
		onReachBottom: function() {
			if (_self.loadingType != 0) {//loadingType!=0;直接返回
				return false;
			}
			_self.loadingType = 1;
			uni.showNavigationBarLoading();//显示加载动画
			page++;//每触底一次 page +1
			uni.request({
				url: httpPath.filePath+"api.php/index/member/my_loan/",
				method:'POST',
				header:{'content-type':'application/x-www-form-urlencoded'},
				data: {page:page,member_id:this.user.member_id},
				success: (res) => {
					if (res.data.result.length==0) {//没有数据
						_self.loadingType = 2;
						uni.hideNavigationBarLoading();//关闭加载动画
						return false;
					}
					for (let i = 0;i < res.data.result.length;i++) {
						res.data.result[i].addtime=timestampToDate(res.data.result[i].addtime)
						res.data.result[i].capital=fmoney(res.data.result[i].capital)
						_self.list.push(res.data.result[i]);
						
					}
					_self.loadingType = 0;//将loadingType归0重置
					uni.hideNavigationBarLoading();//关闭加载动画
					
				}
			});
			// uni.request({
			// 	url: common.api_url+'&interface=assign&api=drugsLists&she='+this.type+'&userId='+this.userInfo.userId+'&page='+page,
			// 	success: function(res) {
			// 		if (res.data.data.list.length==0) {//没有数据
			// 			_self.loadingType = 2;
			// 			uni.hideNavigationBarLoading();//关闭加载动画
			// 			return false;
			// 		}
			// 		for (let i = 0;i < res.data.data.list.length;i++) {
			// 			_self.dataList.push(res.data.data.list[i]);
			// 		}
			// 		_self.loadingType = 0;//将loadingType归0重置
			// 		uni.hideNavigationBarLoading();//关闭加载动画
					
			// 	}
			// });
		},
		methods: {
			
		    goinfo(e){
			   uni.navigateTo({
				url:"jindu?id="+e.currentTarget.dataset.id
			   })
		    },
			// goaddkehu(id){
			// 	uni.navigateTo({
			// 		url:"editkehu"
			// 	})
			// },
			fnGetData(){
				uni.request({
					url: httpPath.filePath+"api.php/index/member/my_loan/",
					method: 'GET',
					data: {page:page,member_id:this.user.member_id},
					success: res => {
						if(res.data.code == "200"){
							this.list = res.data.result;
							if(this.list.length==0){
								this.ishas1=true;
							}else{
								this.ishas1=false;
							}
							for(let i=0;i<this.list.length;i++){
								this.list[i].addtime=timestampToDate(this.list[i].addtime)
								this.list[i].capital=fmoney(this.list[i].capital)
							}
						}
					}
				});
			},
			
		}
	}
</script>

<style>
	@import "../../colorui/main.css";
	page{background-color: #fff;}
	.zhuangtai{position: absolute;top: 63rpx;right: 30rpx;color: #666666;}
	.go_icon{top: 65rpx;}
	
</style>
